
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>佣金明细</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-sm12">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-sm12">
                    <div class="layui-card">
                        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                            <div class="layui-form-item">

                                <div class="layui-inline">
                                    <input type="text" id="dayStart" name="start_date" placeholder="数据开始日期" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" id="dayEnd" name="end_date" placeholder="数据结束日期" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <select name="status">
                                        <option value="">支付状态</option>
                                        <option value="1">待支付</option>
                                        <option value="2">已支付</option>
                                        <option value="3">已失效</option>
                                    </select>
                                </div>


                                <div class="layui-inline">
                                    <input type="text" name="agent_id" placeholder="代理Id" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" name="channel_id" placeholder="投放号Id" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" id="regDate" name="user_reg_date" placeholder="用户注册日期" autocomplete="off" class="layui-input">
                                </div>


                                <div class="layui-inline">
                                    <input type="text" name="uid" placeholder="请输入用户ID" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" name="out_trade_no" placeholder="请输入订单号" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" name="trade_no" placeholder="请输入交易单号" autocomplete="off" class="layui-input">
                                </div>

                                <div class="layui-inline">
                                    <input type="text" name="chargefrom" placeholder="支付号id" autocomplete="off" class="layui-input">
                                </div>


                                <div class="layui-inline">
                                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                    </button>
                                </div>

                                <div class="layui-inline">
                                    总金额：<span class="total_amount">0</span>
                                </div>

                            </div>
                        </div>
                        <div class="layui-card-body">
                            <table id="LAY-user-back-role" lay-filter="LAY-user-back-role"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>



<script src="/static/layuiadmin/layui/layui.js"></script>

<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table
            ,admin = layui.admin;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var start = laydate.render({
            elem: '#dayStart',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date;
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#dayEnd',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = {
                        'date': curDate.getDate(),
                        'month': curDate.getMonth() + 1,
                        'year': curDate.getFullYear()
                    };
                }
                start.config.max = date;
                start.config.max.month = date.month - 1;
            }
        });

        laydate.render({
            elem: '#regDate',
            type: 'date',
            max: nowTime,
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = {
                        'date': curDate.getDate(),
                        'month': curDate.getMonth() + 1,
                        'year': curDate.getFullYear()
                    };
                }
            }
        });
        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-user-back-role', {
                where: field
                ,page: {
                    curr: 1  // 将页码重置为第一页
                }
            });
        });

        table.render({
            elem: '#LAY-user-back-role'
            , url: '/deduct/orderList' //模拟接口
            , page: true //开启分页
            , even: true //开启隔行背景
            , limit: 20
            , cols: [[
                {field: 'id', width: 80, title: 'ID'}
                , {field: 'agent_name', title: '代理',templet:function (d) {
                        if (d.agent_name != ''){
                            return "【"+d.agent_id+"】"+d.agent.account;
                        }else {
                            return  "【"+d.agent_id+"】";
                        }
                    },minWidth: 150}
                , {field: 'channel_name', title: '投放号',templet:function (d) {
                        if (d.channel_name != ''){
                            return "【"+d.channel_id+"】"+d.channel.account;
                        }else {
                            return  "【"+d.channel_id+"】";
                        }
                    },minWidth: 150}
                , {field: 'money', title: '金额'}
                , {field: 'uid', title: '用户id'}
                , {field: 'user_reg_date', title: '用户注册日期'}
                , {field: 'out_trade_no', title: '订单号',minWidth: 200}
                , {field: 'trade_no', title: '交易单号',minWidth: 200}
                , {
                    field: 'pay_type', title: '支付方式', templet: function (d) {
                        if (d.pay_type == '1') {
                            return '微信';
                        } else if (d.pay_type == 2) {
                            return '支付宝';
                        } else {
                            return '未知';
                        }
                    }, align: 'center'
                }
                , {field: 'chargefrom', title: '支付号id'}
                , {
                    field: 'status', title: '订单状态', templet: function (d) {
                        if (d.status == 2) {
                            return '<span style="color: #5FB878">已支付</span>';
                        } else {
                            return '未支付';
                        }
                    }
                }
                , {field: 'create_time', title: '创建时间'}
            ]]
            ,done: function(res, curr, count){
                $('.total_amount').html(res.totalRow.total_fee);
            }
        });
    });
</script>
</body>

</html>

